home *** CD-ROM | disk | FTP | other *** search
- Path: news.vub.ac.be!rc4!apardon
- From: apardon@rc1.vub.ac.be (Antoon Pardon)
- Newsgroups: comp.lang.c++
- Subject: Dynamically initializing static members
- Date: 22 Mar 1996 10:11:18 GMT
- Organization: Brussels Free Universities (VUB/ULB), Belgium
- Message-ID: <4ituc6$c1h@rc1.vub.ac.be>
- NNTP-Posting-Host: mailhost.vub.ac.be
- X-Newsreader: TIN [version 1.2 PL2]
-
- I am playing with the idea of somekind of classregistration.
-
- The registration class would provide for a function:
-
- unsigned int Registrate(const char *name);
-
- This would keep the name of the function stored somewhere and
- would return a registration ID.
-
- The idea would be to include a static int into the class that
- would store this ID something like this
-
- class MYCLASS {
- static unsigned int
- Registration_ID
-
- ...
-
- }
-
- The problem now is how do I assign this Registration_ID
- automatically. In Modula 2 you have initialisation code
- that is called at the start of the program where you might
- then put code similar to
-
- MYCLASS::Registration_D = Registrate("MYCLASS");
-
- Is something similar possible in C++ or do I have to
- do it in a different way? I looked at the FAQ but
- couldn't find an answer there.
-
- --
- All opinions expressed herein are currently under revision
- ==========================================================
- Antoon Pardon Brussels Free University Computing Centre
- ==========================================================
-